<?php 
    $node = $this->get_data('node');
    $attribute = $this->get_data('attribute');
    
    $parent_id = (int) $node['parent_id'];
    $parent_caption = false;
    if ($parent_id) {
        $parent_caption = m('node')->get_caption($node['parent_id']);
    }
    
    $show_keywords = isset($attribute['show_keywords']) ? (int) $attribute['show_keywords'] : 1;
    $show_action = isset($attribute['show_action']) ? (int) $attribute['show_action'] : 0;
    
    $description_length = isset($attribute['description_length']) ? (int) $attribute['description_length'] : 0;
    
    
    $description = $node['description'];
    $show_pop = 0;
    if ($description_length > 0 && isset($description[$description_length])) {
        $short_description = tos_html_strip($description, $description_length);
        $show_pop = isset($attribute['show_pop']) ? (int) $attribute['show_pop'] : 1;
        if ($show_pop) {
            $short_description .= '<a href="javascript:;" onclick="z.show_pop(\'' . addslashes(tos_html_strip($description)) . '\', this)">more</a>';
        }
    } else {
        $short_description = tos_html_strip($description);
    }
?>
<div class="node">
    <div class="thumbnail"><?php echo tos_img($node['thumbnail'] ? $node['thumbnail'] : 'img/icon/blueprint.png', 60, 40);?></div>
    <h2 class="caption">
        <?php if ($parent_caption):?>
        <a class="parent" href="<?php echo tos_router_url(array('url' => $parent_caption['url_segment']));?>">[<?php echo $parent_caption['caption']; ?>]</a> - 
        <a href="<?php echo tos_router_url(array('url' => $parent_caption['url_segment'] . '/' . $node['url_segment']));?>"><?php echo $node['caption']; ?></a>
        <?php else:?>
        <a href="<?php echo tos_router_url(array('url' => $node['url_segment']));?>"><?php echo $node['caption']; ?></a>
        <?php endif;?>
    </h2>
    <?php 
    if ($show_keywords) {
        m('node')->block_node_keywords($node['id'])->display();
    }
    ?>
    <div class="description"><?php echo $short_description; ?></div>
    
    <?php if ($show_action): ?>
    <div class="action">
        <ul class="inline-block">
            <li class="action"><a href="<?php echo tos_router_url(array('m' => $node['type'], 'a' => 'edit', 'node_id' => $node['id']));?>">Edit</a></li>
            <li class="action"><a href="<?php echo tos_router_url(array('m' => $node['type'], 'a' => 'display', 'node_id' => $node['id']));?>">Detail</a></li>
            
        </ul>
    </div>
    <?php endif; ?>
</div>